package com.jvyou.app.ds.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jvyou.app.ds.domain.entity.AnswerRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 学员答题记录表(AnswerRecord)表数据库访问层
 *
 * @author 橘柚
 * @since 2025-04-21 20:37:57
 */
public interface AnswerRecordMapper extends BaseMapper<AnswerRecord> {

    @Select("SELECT IF(COUNT(*)=0, 0, ROUND(SUM(is_correct)*100.0/COUNT(*),2)) AS correct_rate FROM ds_answer_record WHERE question_id=#{questionId}")
    Double getCorrectRate(@Param("questionId") Long questionId);
}
